home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.02 Feb 95 / Yenta / Periodic Tasksƒ / CPPWatchWriteTask.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-04  |  1.4 KB  |  49 lines  |  [TEXT/KAHL]

  1. /********************************************************* DEFINITION
  2.     DATE:    9/17/93
  3.     AUTHOR: Eric R. Rosé
  4.  
  5.     CLASS:  CPPWatchWriteTasks
  6.     
  7.     SUPERCLASS: CPeriodicTask
  8.     
  9.         This class waits until there are no write tasks in the queue
  10.         it belongs to and then disposes of the memory it is
  11.         started up with.  
  12.         Q:  What could you possibly use this for?
  13.         A:  When you spawn a write task, it has to be assured that the
  14.             data it is writing out won't get cleared.  Normally you could
  15.             tell it that it has ownership of the data and let it dispose
  16.             of it when it is done.  However, if you spawn many write tasks,
  17.             all with the same data, you have no guarantee the one you gave 
  18.             ownership of the data to will complete last, or, indeed, at all.
  19.             To solve this, do not give any of the write tasks ownership of
  20.             the data, then spawn a CWatchWriteMemTask and give it the
  21.             responsibility of disposing of the memory after all of the write
  22.             tasks have completed.
  23.     
  24. ********************************************************************/
  25.  
  26. #pragma once
  27.  
  28. #include <CPPPeriodicTask.h>
  29.  
  30. class CPPTaskManager;
  31.  
  32. class CPPWatchWriteTasks : public CPPPeriodicTask {
  33.  
  34. public:
  35.                     CPPWatchWriteTasks (CPPTaskManager *TaskManager, 
  36.                                         long minPeriod);
  37.                     ~CPPWatchWriteTasks (void);
  38.             
  39.     virtual    char     *ClassName (void);
  40.  
  41.     void             StartWatchTask (Ptr Data);
  42.  
  43.     virtual    void    DoPeriodicAction (void);
  44.     virtual    void    DoCompletedAction (void);
  45.         
  46. private:
  47.     Ptr        dataToWatch;
  48. };
  49.